# HG changeset patch # User Matt Harbison # Date 1726159980 14400 # Node ID f81e0ce5103a48f0c479732295e1a59f80a07b0f # Parent 8c39ba94accefaec6052c8b8f03745ca6ac1ec51 typing: simplify archive.gz writing and drop a few pytype suppressions I was waiting until 3.8 to use `Literal` to fix this, but there's also the ":" and "|" characters that are passed along here, meant only for the non-gz archive types. But manipulating what the local caller passes is silly- we know we're writing, so just open it for writing. As an added bonus, PyCharm stops flagging the call too (since it doesn't know about pytype suppression comments). diff -r 8c39ba94acce -r f81e0ce5103a mercurial/archival.py --- a/mercurial/archival.py Thu Sep 12 12:38:43 2024 -0400 +++ b/mercurial/archival.py Thu Sep 12 12:53:00 2024 -0400 @@ -163,16 +163,7 @@ mtime=mtime, ) self.fileobj = gzfileobj - return ( - # taropen() wants Literal['a', 'r', 'w', 'x'] for the mode, - # but Literal[] is only available in 3.8+ without the - # typing_extensions backport. - # pytype: disable=wrong-arg-types - tarfile.TarFile.taropen( # pytype: disable=attribute-error - name, pycompat.sysstr(mode), gzfileobj - ) - # pytype: enable=wrong-arg-types - ) + return tarfile.TarFile.taropen(name, "w", gzfileobj) else: try: return tarfile.open(